var app = getApp()
Page({

  data: {
    comments:[],
    comment:''
  },
  onLoad: function (options) {
    var that = this
    var comments = that.data.comments
    wx.request({
      url: app.appData.contextPath + 'findComments',
      data: {
        
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        var commentsAway = res.data
        console.log(commentsAway[0]+'chandu')
        for (var i = 0; i < commentsAway.length; i++) {
          comments[i] = commentsAway[i];
        }
        that.setData({
          comments: comments
        });
      }
    })
  },
  onReady: function () {
    
  },

  onShow: function () {
    
  },

  onHide: function () {
    
  },
  onUnload: function () {
    
  },

  onPullDownRefresh: function () {
    
  },

  onReachBottom: function () {
    
  },
  onShareAppMessage: function () {
    
  },
  comment: function (e) {
    var that = this
    var comment = e.detail.value
    that.setData({
      comment:comment
    })
  },
  confirm: function () {
    var that = this
    var comment = that.data.comment
    wx.request({
      url: app.appData.contextPath + 'addComment',
      data: {
        comment: comment
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        wx.switchTab({
          url: '../location/location',
        })
      }
    })




  }
})